<?php

class Consignor_info extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'Consignor_info':
	 * @var integer $id
	 * @var string $name
	 * @var string $legal_person_name
	 * @var string $office_tel
	 * @var string $office_fax
	 * @var string $registered_address
	 * @var double $registered_capital
	 * @var string $nature
	 * @var string $storage_manager
	 * @var string $dispatcher
	 * @var string $reckoner
	 * @var string $term
	 * @var integer $state
	 * @var string $create_time
	 */
	
	//弹出窗口临时用变量
	public $addr;
	public $link_name;
	public $mobile_no;
	
	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'consignor_info';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		return array(
			array('name','length','max'=>100),
			array('legal_person_name','length','max'=>30),
			array('office_tel','length','max'=>25),
			array('office_fax','length','max'=>25),
			array('registered_address','length','max'=>100),
			array('nature','length','max'=>30),
			array('storage_manager','length','max'=>30),
			array('dispatcher','length','max'=>30),
			array('reckoner','length','max'=>30),
			array('state', 'numerical', 'integerOnly'=>true),
			array('registered_capital', 'numerical'),
			array('term', 'type','type'=>'date','message'=>'{attribute} 必须为日期型(年-月-日)'),
			array('registered_capital', 'match' ,'pattern' => '/^\d{1,16}(\.\d{1,2})?$/','message'=>'{attribute} 整数位最多16位，小数位2位'),
			array('name,legal_person_name,office_tel,office_fax,registered_address,nature,
			storage_manager,dispatcher,reckoner,registered_capital', 'required'),
		);
	}
	
	/**
	 * Prepares attributes before performing validation.
	 */
	protected function beforeValidate($on)
	{
		if($this->isNewRecord){
			$this->state=0;
			$this->create_time=date('Y-m-d G:i:s');
		}
		return true;
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => '索引号',
			'name' => '货主名称',
			'legal_person_name' => '法人',
			'office_tel' => '公司电话',
			'office_fax' => '公司传真',
			'registered_address' => '注册地址',
			'registered_capital' => '注册资金',
			'nature' => '企业性质',
			'storage_manager' => '储运主管人',
			'dispatcher' => '调度人',
			'reckoner' => '结算人',
			'term' => '合同到期日',
			'state' => '状态',
			'create_time' => '创建时间',
		);
	}
}